<html>
  <head>
    <script>
      function appendResults(text) {
    	  alert("Before Results");
        var results = document.getElementById('results');
        results.appendChild(document.createElement('P'));
        results.appendChild(document.createTextNode(text));
        alert("After Results");
      }

      function makeRequest() {
    	  alert("Before Make Request");
        var request = gapi.client.calendar.events.list({
	      'calendarId': 'primary'
	    });
        request.execute(function(response) {
        	alert(response);
          appendResults("Length : "+response.items);
        });
        alert("After Execute");
      }

      function load() {
    	  alert("Before Load");
        gapi.client.setApiKey('AIzaSyARQ202HL0KwWVp6hUpJXZiM3ydkj8YxyI');
        gapi.client.load('calendar', 'v3', makeRequest);
        alert("After Load");
      }
    </script>
    <script src="https://apis.google.com/js/client.js?onload=load"></script>
  </head>
  <body>
    <div id="results"></div>
  </body>
</html>